Skip to content

Conversation

@CraigMacomber
Copy link
Contributor

@CraigMacomber CraigMacomber commented Dec 2, 2025

Description

Since simple schema can now contain view schema specific data, but might also be derived from stored schema, and might also be storing only a subset of its view specific data that it can hold (like when snapshotting for compatibility tests) using it is rather error prone.

This refactoring attempts to better clarify what the semantics of a given simple schema are by allowing them to be typed as either view or stored, and providing more specific names and docs to the compatibility snapshotting APIs.

This also refactors how we generate stored schema: now we transform a simple schema for a view to a simple schema for stored schema, then convert that to the persisted format. This redesign separates the concerns for persisted format conversion and the semantics of things like staged schema which get processes when converting from view to stored.

This results in some deduplication of logic, and allows all schema transformation logic to be applied directly to simple-schema.
This change could be followed up with some further changes to better remove stored schema from the alpha APIs, and replace those APIs with use of stored-simple-schema and thus shrinking the package API surface area and making its types more interoperable.

getUnhydratedContext has been improved to give better asserts when uses re-entrantly.

Breaking Changes

Several stored and simple schema alpha APIs have been impacted, but all stable APIs should behave as is.

Reviewer Guidance

The review process is outlined on this wiki page.

@CraigMacomber CraigMacomber changed the title To stored refactor Simple-Schema and to stored refactor Dec 3, 2025
@CraigMacomber CraigMacomber marked this pull request as ready for review December 3, 2025 18:36
@CraigMacomber CraigMacomber requested review from a team as code owners December 3, 2025 18:36
Copilot AI review requested due to automatic review settings December 5, 2025 02:20
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the simple-schema system to better distinguish between view and stored schema types, improving type safety and API clarity. The changes introduce a SchemaType enum to explicitly type schemas as either View or Stored, rename compatibility snapshot APIs for better clarity, and refactor schema transformation logic to separate concerns between format conversion and semantic transformations.

Key changes:

  • Introduces SchemaType enum with Stored and View variants to parameterize schema interfaces
  • Renames encodeSimpleSchema/decodeSimpleSchema to encodeSchemaCompatibilitySnapshot/decodeSchemaCompatibilitySnapshot
  • Refactors schema transformation to convert view→stored simple-schema before converting to persisted format
  • Adds reentrancy protection to getUnhydratedContext for better debugging
  • Removes definitionsInternal from TreeViewConfiguration public API surface

Reviewed changes

Copilot reviewed 55 out of 55 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/framework/fluid-framework/api-report/*.api.md Removes definitionsInternal from TreeViewConfiguration in all API reports
packages/dds/tree/src/simple-tree/simpleSchema.ts Adds SchemaType enum and parameterizes all simple schema interfaces with it
packages/dds/tree/src/simple-tree/toStoredSchema.ts Major refactoring to transform view→stored simple-schema, then to persisted format
packages/dds/tree/src/simple-tree/treeSchema.ts New file defining TreeSchema interface and createTreeSchema function
packages/dds/tree/src/simple-tree/createContext.ts Adds reentrancy guard to getUnhydratedContext
packages/dds/tree/src/simple-tree/api/*.ts Updates to use renamed snapshot APIs and new schema transformation functions
packages/dds/tree/src/simple-tree/core/*.ts Updates to support new SchemaType parameterization and transformation options
packages/dds/tree/src/simple-tree/node-kinds/**/*.ts Updates all node type interfaces to specify SchemaType.View
packages/dds/tree/src/test/**/*.spec.ts Test updates to use new APIs and validate schema transformations
packages/dds/tree/src/shared-tree/*.ts Updates to properly type stored schema exports as SchemaType.Stored

@github-actions
Copy link
Contributor

github-actions bot commented Dec 5, 2025

🔗 No broken links found! ✅

Your attention to detail is admirable.

linkcheck output


> [email protected] ci:check-links /home/runner/work/FluidFramework/FluidFramework/docs
> start-server-and-test "npm run serve -- --no-open" 3000 check-links

1: starting server using command "npm run serve -- --no-open"
and when url "[ 'http://127.0.0.1:3000' ]" is responding with HTTP status code 200
running tests using command "npm run check-links"


> [email protected] serve
> docusaurus serve --no-open

[SUCCESS] Serving "build" directory at: http://localhost:3000/

> [email protected] check-links
> linkcheck http://localhost:3000 --skip-file skipped-urls.txt

Crawling...

Stats:
  243138 links
    1776 destination URLs
    2015 URLs ignored
       0 warnings
       0 errors


@CraigMacomber CraigMacomber merged commit b0513a6 into microsoft:main Dec 5, 2025
32 checks passed
@CraigMacomber CraigMacomber deleted the toStoredRefactor branch December 5, 2025 22:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants